package cn.codergege.demo.service

import cn.codergege.demo.dao.PersonRepository
import cn.codergege.demo.entity.Person
import cn.codergege.demo.entity.QPerson.person
import com.querydsl.core.types.Predicate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service
class PersonService {
   @Autowired
   lateinit var personRepository: PersonRepository

   fun findPersons(name: String): List<Person>? {
      return personRepository.findByName(name)
   }

   fun findPersonsByGender(gender: Int): Iterable<Person>? {
      val predicate: Predicate = person.gender.eq(gender)
      return personRepository.findAll(predicate)
   }
}
